/*
 *
 * Copyright (c) 2021
 * User:Dybala
 * File:UtilsController.java
 * Date:2021/12/02 09:07:02
 */

package com.controller.UserController;

import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@RestController
public class UtilsController {
//    @RequestMapping(value="/*",method = RequestMethod.OPTIONS)
    public ResponseEntity handOptions(HttpServletResponse response, HttpServletRequest request){
        response.setHeader("Access-Control-Allow-Origin", request.getHeader("origin"));
        response.setHeader("Access-Control-Allow-Credentials", "true");
        response.setHeader("Access-Control-Allow-Methods", "GET, HEAD, POST, PUT, PATCH, DELETE, OPTIONS");
        response.setHeader("Access-Control-Max-Age", "86400");
        response.setHeader("Access-Control-Allow-Headers", "*");

        return (ResponseEntity) ResponseEntity.noContent();
    }
}
